import { init } from 'snabbdom/build/init'
import { h } from 'snabbdom/build/h'

// 1,引入模块(注意:这个名称不能拼错,拼错取不到值)
import { styleModule } from 'snabbdom/build/modules/style'
import { eventListenersModule } from 'snabbdom/build/modules/eventlisteners'

// 2. 注册模块,为patch函数添加模块对应的能力
const patch = init([
  styleModule,
  eventListenersModule
])

// 3.使用模块
let vNode = h('div#box', {
  style: {
    backgroundColor: 'green',
    height: '200px'
  }
}, [
  h("h1#title", {
    style: {
      color: '#fff'
    },
    on: {
      click () {
        console.log('点击了')
      }
    }
  }, "这是标题内容"),
  h('p', 'p标签')
])

const dom = document.getElementById("app")
var oldVNode = patch(dom, vNode)

vNode = h("div#app", {
  style: {
    color: 'green'
  }
}, h("p#myp", 123))

patch(oldVNode, vNode)